package com.itheima.app.manager.pmsManager;


import com.itheima.commons.PageBean;
import com.itheima.commons.R;
import com.itheima.domain.db.pms.PmsBrand;
import com.itheima.service.pmsService.BrandService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class BrandManager {

    @DubboReference
    BrandService brandService;

    //根据品牌名称分页获取品牌列表
    public R getBrandList(String keyword, Integer pageNum, Integer pageSize) {

        PageBean<PmsBrand> brandPageBean = brandService.getBrandList(keyword,pageNum,pageSize);
        return R.ok(brandPageBean);
    }

    //添加品牌
    public R saveBrand(PmsBrand brand) {
        brandService.saveBrand(brand);
        return R.ok(null);
    }

    //批量删除品牌
    public R deleteBrand(List<Long> ids) {
        brandService.deleteBrand(ids);
        return R.ok(null);
    }

    //删除品牌
    public R deleteById(Integer id) {
        brandService.deleteById(id);
        return R.ok(null);
    }

    public R listAll() {
        List<PmsBrand> brandList = brandService.listAll();
        return R.ok(brandList);
    }

    public R updateFactoryStatus(Integer factoryStatus, Integer[] ids) {
        brandService.updateFactoryStatus(factoryStatus,ids);
        return R.ok(null);
    }

    public R updateShowStatus(Integer showStatus, Integer[] ids) {
        brandService.updateShowStatus(showStatus,ids);
        return R.ok(null);
    }

    public R updateById(PmsBrand brand) {
        brandService.updateById(brand);
        return R.ok(null);
    }

    public R getById(Long id) {
        return R.ok(brandService.getById(id));
    }
}
